<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        body,html {
            height: 100%;
            padding: 0;
            margin: 0;
        }
        .mask {
            width: 100%;
            height: 100%;
            position: fixed;
            top: 0;
            left: 0;
            display: none;
            background: rgba(0, 0, 0, 0.6);
        }
        .login {
            width: 400px;
            height: 300px;
            cursor: pointer;
            background-color: #fff;
            margin: 200px auto;
        }
    </style>
</head>
<body>
<div class="mask">
    <div class="login" id="login"></div>
</div>

<a href="#">登陆</a>
<script src="animate.js"></script>
<script>
    var mask = document.getElementsByClassName('mask')[0];
    var a  = document.getElementsByTagName('a')[0];
    
    a.onclick = function (event) {
        event = event || window.event;
        show(mask);
        if(event && event.stopPropagation){
            event.stopPropagation();
        }else{
            event.cancelBubble = true;
        }
    }
    document.onclick = function (event) {
        event = event || window.event;

        var aaa = event.target?event.target:event.srcElement;
        if(aaa.id != 'login'){
            mask.style.display = 'none';
        }
    }
</script>
</body>
</html>